
import {HttpClient} from "@angular/common/http";
import {AwardService} from "../svrs/award.service";
import {Award, Prize, UserInfo, Winning} from "../svrs/domain";
import {Router, RouterStateSnapshot, ActivatedRoute} from "@angular/router";
import {Component, ViewChild} from '@angular/core';
import { Observable, timer } from 'rxjs';
import {InfiniteLoaderComponent, ToastService} from "ngx-weui";

@Component({
  selector: 'zm-awards',
  templateUrl: './awards.component.html',
  styleUrls: ['./awards.component.css']
})
export class AwardsComponent {
  @ViewChild('success') toast;
  @ViewChild('comp') cddd;
  restartBtn = false;
  configsss={
    height: '80vh'
  }
  award:Award[];
  constructor(private svr:AwardService,
              private rs:ActivatedRoute,
              private toastSvr: ToastService) {
    svr.getAwards().subscribe(data => this.award = data);
  }
  onLoadMore(cn:InfiniteLoaderComponent) {
    this.svr.getAwards().subscribe(data =>
    {
      if (this.award.length >=20){
        cn.setFinished();
        return;
      } else {
        this.award.push(...data);
        cn.resolveLoading();
        this.restartBtn = true;
      }
    })
  }
  eres(){
    this.award.length=0;
    this.cddd.restart()
  }
  onShow(){
     this.toast.onShow();
     // this.toastSvr.hide();
     // this.toastSvr.loading("加载提示");
     // this.toastSvr.hide();
     // this.toastSvr.show("最后一个");
   }
  onShowSvrOfToasa(){
    this.toastSvr.loading("加载提示");
  }
  ngOnInit() {

  }
}
